<h2>Search agreement</h2>
<div class="form-search">
	<%= render 'search' , {:locale=>params[:locale]} %>
</div>
<h2>Listing agreements</h2>
<table>
	<tr>
		<th>NO.</th>
		<th>Agreement no</th>
		<th>Customer</th>
		<th>Agent</th>
		<th><%= t(:view)%></th>
		<th><%= t(:edit)%></th>
		<th><%= t(:delete)%></th>
	</tr>
	<% @agreements.each_with_index do |agreement,index| %>
	<tr>
		<td><%= index+1 %></td>
		<td><%= agreement.agreement_no %></td>
		<td><%= agreement.customer.code+' ('+agreement.customer.first_name+')' %></td>
		<td><%= agreement.user.login %></td>
		
		<td class="command"> <% if can? :read, Agreement %>
		<%= link_to image_tag("view-icon.png", :border => 0) , agreement  %>
		<% else %>
		-
		<% end %> </td>
		<td class="command"> <% if can? :update, Agreement %>
		<%= link_to image_tag("edit-icon.png", :border => 0) , edit_agreement_path(agreement)  %>
		<% else %>
		-
		<% end %> </td>
		<td class="command"> <% if can? :destroy, Agreement %>
		<%= link_to image_tag("delete-icon.png", :border => 0) , agreement , :confirm => 'Are you sure?', :method => :delete %>
		<% else %>
		-
		<% end %> </td>
		
	</tr>
	<% end %>
</table>
<%= will_paginate @agreements %>
<% if can? :create , Agreement %>
<%= link_to image_tag("add-icon.png", :border => 0) , new_agreement_path , {:class => 'form-command'} %>
<%= link_to 'New Agreement', new_agreement_path %>
<% end %> 